package com.eemint.config;


import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;

/*** 
 *  Copyright (C), 2019,12, eemint
 *  File name and path : com.eemint.config.MailInfo.java
 *  Author : Dallas,    
 *  Version : 1.0,    
 *  First complete date : 2019/12/24 11:50
 *  Description :  接口返回实体类
 *  History:  nothing
 *    
 ***/
@Data
public class WebResult<T> {
    public static final Integer SUCCESS = 1;
    public static final Integer FAILED = 0;

    /**
     * 状态码
     */
    @JsonProperty("code")
    private Integer code;
    /**
     * 信息
     */
    @JsonProperty("msg")
    private String msg;

    /**
     * 数据
     */
    @JsonProperty("data")
    private T data;

    public WebResult() {
    }

    public WebResult(Integer code) {
        this.code = code;
    }

    public static WebResult fialed(){
        WebResult errorWebResult = new WebResult(WebResult.FAILED);
        errorWebResult.setMsg("请求失败");
        return errorWebResult;
    }

    public static WebResult success(Object data){
        WebResult successWebResult = new WebResult(WebResult.SUCCESS);
        successWebResult.setMsg("请求成功");
        successWebResult.setData(data);
        return successWebResult;
    }
}
